//定义表示计积分的类
class Panel {
    score= 0;
    level= 1;
    scoreEle: HTMLElement;
    levelEle: HTMLElement;
    //设置一个最大等级
    maxLevel: number;
    constructor(maxLevel:number = 10) {
        this.scoreEle = document.getElementById('score')!;
        this.levelEle = document.getElementById('level')!;
        this.maxLevel = maxLevel
    }
    //分数自增
    addScore() {
        this.scoreEle.innerHTML = ++this.score + ''
        if (this.score % 10 == 0) {
            this.upLevel()
        }
    }
    //等级提升(每10分升一级)
    upLevel() {
        if (this.level < this.maxLevel) {
            this.levelEle.innerHTML = ++this.level + ''
        }
    }
}
//测试代码
// const panel = new Panel(10)

// for (let i = 0; i < 80; i++){
//         panel.addScore()
// }
export default Panel;